//
//  ARTNetworkService.m
//  ChartsDemo
//
//  Created by yunda on 2021/10/14.
//

#import "ARTNetworkService.h"
#import "NSError+Extension.h"

@implementation ARTNetworkService

+ (void)requestWithDataModel:(ARTRequestModel *)dataModel success:(ResponseSuccess _Nullable)successBlock failure:(ResponseFailure _Nullable)failureBlock{
    [ARTNetwork requestWithDataModel:dataModel progressCallback:^(CGFloat value) {
        
    } successdCallback:^(ARTResponseModel * _Nonnull responseModel) {
        if (responseModel.code == 0) {
            if (successBlock) {
                successBlock(responseModel.data);
            }
        }else{
            if (failureBlock) {
                failureBlock(responseModel.msg);
            }
        }
    } failedCallback:^(NSError * _Nullable error) {
        if (failureBlock) {
            NSError *newError = [NSError j_customError:error];
            failureBlock(newError.localizedDescription);
        }
    }];
}

/// 检测app版本
+ (void)request_checkAppVersion_WithParameter:(NSDictionary *)parameter success:(ResponseSuccess _Nullable)successBlock failure:(ResponseFailure _Nullable)failureBlock{
    ARTRequestModel *requestModel = [[ARTRequestModel alloc]initWithMethod:kRequestMethod_verionCheck];
    requestModel.parameter = parameter;
    [self requestWithDataModel:requestModel success:successBlock failure:failureBlock];
}

@end
